//>>built
function txt2json(_1){var _2={identifier:"id",label:"name",items:[]};if(_1!=""){var _3={},_4=dojo.fromJson("["+_1.substr(1)+"]"),_5,_6,_7,_8;for(var i=0,t=_4.length;i<t;i++){_5=_4[i].id;_3[_5]=_4[i];_7=_5.lastIndexOf("_");var _9=_5.split("_");if(i==0){_8=_9.length;}else{}if(_8==_9.length){_3[_5]["type"]="root";}if(_7>-1&&_9.length>_8){_6=_5.substr(0,_7);if(!(_3[_6]["children"])){_3[_6]["children"]=[];}_3[_6]["children"].push({_reference:_5});}_2["items"].push(_3[_5]);}}return _2;};

function TreeNode(data){
	var _json={identifier:'id',label:'name',items:[]};
	if(data!=""){
		var _obj={},_arrObj=dojo.fromJson("["+data.substr(1)+"]"),_id,_pId;

		for(var i=0,t=_arrObj.length;i<t;i++){
			_id = _arrObj[i].id;
			_pId=_arrObj[i].pid;
			
			_obj[_id]=_arrObj[i];
			if("0"==_pId||"无"==_pId){
				_obj[_id]["type"]="root";
				_json["items"].push(_obj[_id]);
			}
			if(_obj[_pId]){
				if(!(_obj[_pId]["children"])){_obj[_pId]["children"]=[]};
				_obj[_pId]["children"].push({_reference:_id});				
				_json["items"].push(_obj[_id]);
			}
		}
	}
	return _json;
}